#include "Winsock2SocketFactory.h"

bool net::Winsock2SocketFactory::_initialised;
net::Winsock2SocketFactory net::Winsock2SocketFactory::_instance;

net::Winsock2SocketFactory::Winsock2SocketFactory(void)
{
	_initialised = true;
}

net::Winsock2SocketFactory::~Winsock2SocketFactory(void)
{
	_initialised = false;
}

net::Winsock2SocketFactory* net::Winsock2SocketFactory::getInstance(void)
{
    return _initialised ? &_instance : 0;
}

void net::Winsock2SocketFactory::release(void)
{
	list<Socket*>::iterator it;
    for (it=sockets.begin();it!=sockets.end();it++)
    {
        delete (*it);
    }
}

net::Socket* net::Winsock2SocketFactory::createSocket(void)
{
	return 0;
}

net::ClientSocket* net::Winsock2SocketFactory::createClientSocket(string serverHost, string serverPort)
{
	ClientSocket* cs = new Winsock2ClientSocket(serverHost, serverPort);
    sockets.push_back(cs);
    return cs;
}


net::ServerSocket* net::Winsock2SocketFactory::createServerSocket(int portNumber)
{
	ServerSocket* ss = new Winsock2ServerSocket(portNumber);
    sockets.push_back(ss);
    return ss;
}
